package com.xzz.finger;

/**
 * @author: hhz
 * @create: 2022-02-21 15:48
 * 剑指 Offer 24. 反转链表
 **/
public class ReverseList {
    public static void main(String[] args) {
        ListNode l1 = new ListNode(1);
        ListNode l2 = new ListNode(3);
        ListNode l3 = new ListNode(2);
        l1.next = l2;
        l2.next = l3;
        ListNode node = reverseList(l1);
        System.out.println();
    }
    public static ListNode reverseList(ListNode head) {
        if(head==null || head.next==null){
            return head;
        }
        ListNode node = reverseList(head.next);
        head.next.next = head;
        head.next= null;
        return node;

    }
}
